﻿using Keras.Models;
using Numpy;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace KerasNetHelper
{
    public partial class TestForm : Form
    {
        public TestForm()
        {
            InitializeComponent();
            this.Test4();
        }

        private void Test()
        {
            var loaded_model = Sequential.ModelFromJson(File.ReadAllText("model.json"));
            loaded_model.LoadWeight("model_weights.h5");

            var x = np.array(new double[,] { { 0, 0, 1, 1 }, { 0, 1, 1, 2 } });

            var y = loaded_model.Predict(x);
        }

        private void Test2()
        {
            //读取模型
            var loaded_model = Sequential.LoadModel("my_model3.h5");
            //初始化参数
            var inputParam = new InputParamSet();
            var paramList = new List<double>
            {
                0.555555556, 0.360465116, 0.202991243, 0.228571429, 0.193468705, 0.22370895,  0.39197787,  0.399536097, 0.40625, 0.116607774, 0.748299337, 0.006713631, 1,   1,   1,0.568967964
            };
            //添加一万个相同的参数
            for (int index = 0; index < 1E2; index++)
                inputParam.Add(paramList);
            var y = inputParam.Predict();
            var y2 = inputParam.PredictOneByOne(loaded_model);
            var i = 1;
        }

        private void Test3()
        {
            //读取模型
            KerasModel.GetBaseModel("skeleton_1200steps.h5");
            var paramList = new List<double>
            {
                0.26, 0.24, 0.2688, 0.22, 0.775758
            };
            //初始化参数
            var inputParam = new InputParamSet();
            for (int index = 0; index < 1E2; index++)
                inputParam.Add(paramList);
            var y = inputParam.Predict();
            //var y2 = inputParam.PredictOneByOne(loaded_model);
            var i = 1;
        }

        private void Test4()
        {
            //读取模型
            KerasModel.GetBaseModel("骨架数据0922归一.h5");
            //构造参数
            var paramList = new List<double>
            {
                0.71, 0.41, 0.32, 0.54
            };
            //初始化参数
            var inputParam = new InputParamSet();
            inputParam.Add(paramList);
            var y = inputParam.Predict();
        }
    }
}
